<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="com.mobilottery.ui.ValidationForm"%>
<%@page import="java.util.List"%>
<%@page import="com.mobilottery.server.Game"%>
<%@page import="java.util.Date"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/pages/template/page-begin.jspf" %>
<%
	_pageTitle = "Active Games | Admin"; 
	_pageId = "activegames"; 
	_mainPageId = "admin"; 
%>
<%@ include file="/pages/template/head-begin.jspf" %>
<%@ include file="/pages/template/head-end.jspf" %>

<body>
	<%@ include file="/pages/template/content-begin.jspf" %>
	<%@ include file="/pages/admin/admin-bar-left.jspf" %>
	
	<div class="fillContent">	
	<div id="content">	
	<h3>Active Games</h3>
	<div class="contentFillBox contentFillTableBox">
		<table class="dataTable">
			<tr>
				<!-- th class="actionColumn"></th-->
				<th class="dataColumn">ID</th>
				<th class="dataColumn">State</th>
				<th class="dataColumn" style="width:100px;">Start</th>
				<th class="dataColumn" style="width:100px;">Close</th>
				<th class="dataColumn" style="width:100px;">Result</th>
				<th class="dataColumn">Winning #</th>
				<th class="dataColumn">Wins</th>
				<th class="dataColumn">Price</th>
				<th class="dataColumn">Max Prize</th>
			</tr>
		<%!
			private String formatDate(Date date)
			{
				return ValidationForm.DATE_FORMAT.format(date);
			}
			private String formatPrice(Float price)
			{
				return ValidationForm.PRICE_FORMAT.format(price);
			}
		%>
		<%			
			List<Game> games = GameProvider.getInstance().getGameManager().getActiveGames();
			boolean oddRow = true;
			for(Game game:games)
			{
		%>	
				<tr class='<%=oddRow ? "odd" : "even"%>Row'>
					<!-- td class="actionColumn"><a href="?action=delete" title="Delete Game'<%=game.getId()%>'">Delete</a></td-->
					<td class="dataColumn" title="<%=game.getId()%>"><%=game.getId()%></td>					
					<td class="dataColumn" title="State: <%=game.getStatus()%>"><%=game.getStatus()%></td>					
					<td class="dataColumn" title="Opens: <%=formatDate(game.getOpenDate())%>"><%=formatDate(game.getOpenDate())%></td>					
					<td class="dataColumn" title="Closes: <%=formatDate(game.getCloseDate())%>"><%=formatDate(game.getCloseDate())%></td>					
					<td class="dataColumn" title="Result: <%=formatDate(game.getResultDate())%>"><%=formatDate(game.getResultDate())%></td>					
					<td class="dataColumn" title="Winnings: <%=game.getTotalWinings()!=null?game.getTotalWinings().toString():"-"%>"><%=game.getTotalWinings()!=null?game.getTotalWinings().toString():"-"%></td>					
					<td class="dataColumn" title="Cost: <%=formatPrice(game.getParticipationCost())%>"><%=formatPrice(game.getParticipationCost())%></td>					
					<td class="dataColumn" title="Max Prize: <%=formatPrice(game.getMaxPrize())%>"><%=formatPrice(game.getMaxPrize())%></td>					
				</tr>
		<%
				oddRow=!oddRow;
			}
		%>
		</table>
	</div>
	</div>
	</div>

	<jsp:include page="/pages/template/content-end.jspf" />
	
</body>
</html>
